<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <%@ include file="../../include/head.jsp"%>
    <%@ include file="../../include/layui.jsp"%>
    <title>编辑</title>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <form class="layui-form" action="">
                <input type="hidden" name="userId" value="${user.userId}">
                <div class="layui-form-item">
                    <label class="layui-form-label">用户名</label>
                    <div class="layui-input-block">
                        <input type="text" name="userName" lay-verify="userName" value="${user.userName}" autocomplete="off" placeholder="请输入标题" class="layui-input" >
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">性别</label>
                    <div class="layui-input-block">
                        <input type="radio" name="sex" value="男" title="男" ${user.userGender == '男' ? ' checked="" ' : ''}>
                        <input type="radio" name="sex" value="女" title="女" ${user.userGender == '女' ? ' checked="" ' : ''}>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">出生日期</label>
                        <div class="layui-input-inline">
                            <input type="text" name="userBirth" id="userBirth" lay-verify="date" placeholder="yyyy-MM-dd"
                                   value="<fmt:formatDate value="${user.userBirth}" pattern="yyyy-MM-dd"/>"
                                   autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">限制使用</label>
                        <div class="layui-input-block">
                            <select name="limitUse" lay-filter="aihao">
                                <option value=""></option>
                                <option value="0" ${user.limitUse == 0 ? ' selected="" ' : ''}>否</option>
                                <option value="1" ${user.limitUse == 1 ? ' selected="" ' : ''}>是</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item" pane="">
                    <label class="layui-form-label">爱好</label>
                    <div class="layui-input-block">
                        <input type="checkbox" name="like" value="write" lay-skin="primary" title="写作" checked="">
                        <input type="checkbox" name="like" value="read" lay-skin="primary" title="阅读">
                        <input type="checkbox" name="like" value="game" lay-skin="primary" title="游戏" disabled="">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">启用状态</label>
                    <div class="layui-input-block">
                        <input type="checkbox" ${user.enableStatus == 1 ? ' checked="" ' : ''} name="enableStatus" value="1" lay-skin="switch" lay-text="ON|OFF">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">会员电话</label>
                    <div class="layui-input-block">
                        <input type="text" name="userMobilePhone" lay-verify="title" value="${user.userMobilePhone}" autocomplete="off" placeholder="请输入标题" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">会员电话所属运营商</label>
                    <div class="layui-input-block">
                        <input type="text" name="mobileCarriers" lay-verify="title" value="${user.mobileCarriers}" autocomplete="off" placeholder="请输入标题" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">会员邮箱</label>
                    <div class="layui-input-block">
                        <input type="text" name="userEmail" lay-verify="email" value="${user.userEmail}" autocomplete="off" placeholder="请输入标题" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">会员等级</label>
                    <div class="layui-input-block">
                        <input type="text" name="userLevel" lay-verify="title" value="${user.userLevel}" autocomplete="off" placeholder="请输入标题" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">注册IP</label>
                    <div class="layui-input-block">
                        <input type="text" name="registerIp" lay-verify="ip" value="${user.registerIp}" autocomplete="off" placeholder="请输入标题" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-block">
                        <textarea name="remark" placeholder="请输入内容" class="layui-textarea"></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button type="button" class="layui-btn" lay-submit="" id="submitBtn">提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script type="text/javascript">
    layui.use(['form', 'layer', 'laydate'], function(){
        //日期空间
        layui.laydate.render({
            elem: '#userBirth'
        });

        $('#submitBtn').on('click', function(){
            $.post('${ctx}/user/save', $('form').serialize(), function(result){
                if(result.code == 0){
                    parent.layer.alert('操作成功', {
                        yes: function(index){
                            parent.layer.close(index);
                            closeCurrentTabsPage();
                        }
                    });
                }else{
                    parent.layer.msg(result.msg || '操作失败');
                }
            }, 'json');
        });

        // 校验初始化
        var form = layui.form;
        form.verify({
            userName: function(value, item){
                if(/^[a-zA-Z0-9_\u4e00-\u9fa5\s·]+$/.test(value)){
                    return '用户名不能全为数字';
                }
            }
        });
    });
</script>
</body>
</html>